package pri.hillchen.springbootstd.sso.config.mybatis;

import org.apache.ibatis.reflection.MetaObject;

import java.util.Date;

/**
 * 时间类型字段值填充器
 * Created by hillchen on 2017/10/20 0020.
 */
public class DateFieldFillHandler implements FieldFillHandler {
    private boolean fillWhenEmpty;

    @Override
    public boolean fillWhenEmpty() {
        return fillWhenEmpty;
    }

    public DateFieldFillHandler(boolean fillWhenEmpty) {
        this.fillWhenEmpty = fillWhenEmpty;
    }

    @Override
    public void fillField(String fieldName, MetaObject metaObject) {
        metaObject.setValue(fieldName, new Date());
    }
}
